import { defineStore } from 'pinia';
export interface ISegment {
  points: Array<number>,
  stroke: string,
  strokeWidth: number,
  lineCap: string,
  lineJoin: string,
}
export interface ITextDatas {
  x: number,
  y: number,
  text: string,
  fontSize: number,
  fontFamily: string,
  fill: string,
  align: string,
}
export interface ICircle{
  x: number,
  y: number,
  radius: number,
  fill: string,
}
export function createStore(pageNumber: number, widgetId: string) {
  return defineStore(`p${pageNumber}_${widgetId}`, {
    state() {
      return {
        itemRadius: 0,
        columns: 0,
        color:'',
        lightColor:'',
        lineColor:'',
        rows: 0,
        XGap: 0,
        YGap: 0,
        width: 900,
        height: 720,
        points: [] as Array<number>,
        segment:[] as Array<ISegment>,
        textDatas:[] as Array<ITextDatas>,
        operations:[] as any[],
        changeNumber:0,
        back:0,
        circleData:[]  as Array<ICircle>
      };
    },
    getters: {

    },
    actions: {
      setWidth(value: number) {
        this.width = value
      },
      setHeight(value: number) {
        this.height = value
      },
      setItemRadius(value: number) {
        this.itemRadius = value
      },
      setColor(value: string) {
        this.color = value
      },
      setLineColor(value: string) {
        this.lineColor = value
      },
      setLightColor(value: string) {
        this.lightColor = value
      },
      setColums(value: number) {
        this.columns = value
      },
      setRows(value: number) {
        this.rows = value
      },
      setXGap(value: number) {
        this.XGap = value
      },
      setYGap(value: number) {
        this.YGap = value
      },
      setPoints(value: number[]) {
        this.points = value
      },
      setSegment(value:  Array<ISegment>) {
        this.segment = value
      },
      setTextDatas(value: Array<ITextDatas>) {
        this.textDatas = value
      }, 
      setOperations(value:any[]) {
        this.operations = value
      },
      setChangeNumber() {
        this.changeNumber ++
      },
      setBack() {
        this.back ++
      },
      reset() {
        this.setSegment([])
        this.setTextDatas([])
        this.setOperations([])
        this.setChangeNumber()
        this.setPoints([])
      },
      setCircleData(value:Array<ICircle>){
        this.circleData = value
      },
     
     
    }
  })
}
